import Vue from 'vue'
import App from './App.vue'
import router from './router'
import VueRouter from 'vue-router'
import store from './store'
import ViewUI from 'view-design';
import axios from 'axios'
import Setting from '/setting'
import VueLazyload from 'vue-lazyload'
import 'view-design/dist/styles/iview.css';
import '../src/assets/css/iconfont.css'
import '@/util/rem'

Vue.config.productionTip = false;

Vue.use(ViewUI);

const originalPush = VueRouter.prototype.push
   VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}
 
const originalReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace(location) {
   return originalReplace.call(this, location).catch(err => err)
}


const service = axios.create({
  baseURL: Setting.apiBaseURL,
  timeout: 10000,
  headers: {
    'Content-Type':'multipart/form-data'
  }
});

Vue.prototype._get = function(url,params){
    return new Promise((resolve, reject) => {
      service.get(
          url,
          {params},
      )
          .then(response => resolve(response))
          .catch(error => reject(error));
    });
}

Vue.use(VueLazyload, {
  // 设置懒加载时的占位图
  loading: require('./assets/moren.jpg') ,
  // 设置图片加载失败时的占位图
  error: require('./assets/no.png') 
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
